package com.tmc.task;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tmc.bean.common.CommonResult;
import com.tmc.platform.ctrip.CtripOrderServiceImpl;
import com.tmc.util.DateUtil;

@Service
public class CtripTimerTaskServiceImpl {

	private Log logger = LogFactory.getLog(this.getClass());

	@Autowired
	private CtripOrderServiceImpl ctripService;
	
	private static String format = "yyyy-MM-dd HH:mm:ss";

	public synchronized void run() {
		logger.error("执行一次同步订单！");
		Date current = new Date();
		CommonResult cr = ctripService.syncOrdersFromPlatform(null, DateUtil.toStrDate(DateUtil.addSecond(current, -25), format), DateUtil.toStrDate(current, format));
		if (cr.getMessage() != null || cr.getObj() != null) {
			System.out.println(cr.getMessage() + cr.getObj());
		}
	}

}
